<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="<%=basePath%>backstage/css/H-ui.min.css" rel="stylesheet"
	type="text/css" />
<link href="<%=basePath%>backstage/css/H-ui.admin.css" rel="stylesheet"
	type="text/css" />
<link href="<%=basePath%>backstage/lib/icheck/icheck.css"
	rel="stylesheet" type="text/css" />
<link href="<%=basePath%>backstage/lib/Hui-iconfont/1.0.6/iconfont.css"
	rel="stylesheet" type="text/css" />
<link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.css"
	rel="stylesheet" type="text/css" />
<link href="lib/region/css/city-picker.css" rel="stylesheet"
	type="text/css" />
<link href="lib/webuploader/0.1.5/webuploader.css" rel="stylesheet"
	type="text/css" />
<!-- <link href="lib/region/css/main.css" rel="stylesheet" type="text/css" /> -->
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<link href="<%=basePath%>backstage/css/common.css" rel="stylesheet"
	type="text/css" />
<link href="<%=basePath%>backstage/css/style.css" rel="stylesheet"
	type="text/css" />
<title>添加文章</title>
</head>
<body>
	<div class="pd-20">
		<form action="<%=path%>/backstage/article_addorUpdate" method="POST"
			class="form form-horizontal" id="form-u_article-add"
			onsubmit="return before_submit();">
			<input type="hidden" name="id" value="${article.id}" /><input
				type="hidden" id="article_type" name="article_type" value="2" />

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">自媒体：</label>
				<div id="cat_select_div" class="formControls col-xs-8 col-sm-5">
					<select name="wemediaid" class="select">
						<option value="">请选择自媒体</option>
						<c:forEach items="${wemedialist}" var="wemedia">
							<option
								<c:if test="${article.org_id==wemedia.id}">selected="selected"</c:if>
								value="${wemedia.id}">${wemedia.media_title}</option>
						</c:forEach>
					</select>
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">标题：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input type="text" class="input-text" value="${article.title}"
						placeholder="" id="" name="title" datatype="*" nullmsg="不能为空">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">分类：</label>
				<div id="cat_select_div" class="formControls col-xs-8 col-sm-5">
					<div class="cat_select_div_1" style="margin-bottom: 35px;">
						<div class="formControls col-3">
							<select name="cate_id" class="select">
								<option value="0">选择分类</option>
								<c:forEach items="${article_cates}" var="cate">
									<option
										<c:if test="${article.cate_id==cate.id}">selected="selected"</c:if>
										value="${cate.id}">${cate.cate_name}</option>
								</c:forEach>
							</select>
						</div>
					</div>
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">适应年龄：</label>
				<div class="formControls col-xs-8 col-sm-5">
					年龄上限: <input type="text" required class="input-text"
						style="width: 100px;" placeholder="" id=""
						value="${!empty article.apl_up?article.apl_up:-36500}"
						name="apl_up" datatype="*" nullmsg="不能为空">（天）
					&nbsp;&nbsp;年龄下限: <input type="text" required class="input-text"
						style="width: 100px;" placeholder="" id=""
						value="${!empty article.apl_down?article.apl_down:36500}"
						name="apl_down" datatype="*" nullmsg="不能为空">（天）
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">标签：</label>
				<div id="insert3" class="formControls col-xs-8 col-sm-5">
					<div style="line-height: 28px;">
						<c:forEach items="${article_labs}" var="label">
							${label.label_name}:
							<c:forEach items="${label.childLabel}" var="clabel">
								<input
									<c:if test="${fn:contains(article.label,clabel.label_name)}">checked="checked"</c:if>
									type="checkbox" name="label" value="${clabel.label_name}">&nbsp;${clabel.label_name}&nbsp;&nbsp;
							</c:forEach>
							<br />
						</c:forEach>
					</div>
				</div>
			</div>

			<div class="row cl">
				<input type="hidden" id="img1" name="img1" value="" /> <label
					class="form-label col-xs-4 col-sm-3">图说详情：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<!-- <button onClick="add_new_tushuo();" class="btn btn-success radius"
						type="button">
						<i class="Hui-iconfont">&#xe632;</i> 添加图说
					</button> -->
					<div class="uploader-thum-container">
						<div id="filePicker1">选择图片</div>
					</div>
				</div>
			</div>


			<!-- 图说详情 -->
			<ul id="fileList1" class="uploader-list">
				<c:forEach items="${article.article_resources}" var="resource">
					<li><div class="row cl">
							<label class="form-label col-xs-4 col-sm-3">图片：</label>
							<div class="formControls col-xs-8 col-sm-5">
								<img style="width: 190px; height: 190px;" src="${resource.img}"><input
									type="hidden" value="${resource.img}" name="resource_url">
							</div>
						</div>
						<div class="row cl">
							<label class="form-label col-xs-4 col-sm-3">内容：</label>
							<div class="formControls col-xs-8 col-sm-5">
								<textarea name="resource_description"
									style="resize: none; width: 460px; heigth: 150px;">${resource.description}</textarea>
								<button onclick="deltushuo(this)">删除</button>
							</div>
						</div>
						<hr /></li>
				</c:forEach>
			</ul>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">序值：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input type="text" required class="input-text" placeholder="" id=""
						value="${!empty article.sort?article.sort:1000}" name="sort"
						datatype="*" nullmsg="不能为空">
				</div>
			</div>


			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">作者：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input type="text" class="input-text" value="${article.author}"
						placeholder="" id="" name="author" datatype="*" nullmsg="不能为空">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"></label>
				<div class="formControls col-xs-8 col-sm-5">
					<button onClick="u_article_save_submit();"
						class="btn btn-primary radius" type="submit">保存并提交</button>

				</div>
			</div>
		</form>
	</div>
	</div>
	<script type="text/javascript"
		src="<%=basePath%>backstage/lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript"
		src="<%=basePath%>backstage/lib/layer/2.1/layer.js"></script>
	<script type="text/javascript"
		src="<%=basePath%>backstage/lib/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript"
		src="<%=basePath%>backstage/lib/icheck/jquery.icheck.min.js"></script>
	<script type="text/javascript"
		src="<%=basePath%>backstage/lib/Validform/5.3.2/Validform.min.js"></script>
	<script type="text/javascript"
		src="<%=basePath%>backstage/lib/webuploader/0.1.5/webuploader.min.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="<%=basePath%>backstage/lib/ueditor/1.4.3/ueditor.config.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="<%=basePath%>backstage/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
	<script type="text/javascript" charset="utf-8"
		src="<%=basePath%>backstage/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript" src="<%=basePath%>backstage/js/H-ui.js"></script>
	<script type="text/javascript"
		src="<%=basePath%>backstage/js/H-ui.admin.js"></script>
	<script type="text/javascript">
	var baseurl;
	function u_article_save_submit(){
		$("#form-u_article-add").Validform({
			tiptype:2,
			ajaxPost:true,
			callback:function(form){
				var index = parent.layer.getFrameIndex(window.name);
					if (index){//关闭弹出层
						parent.$('.btn-refresh').click(); 
						parent.layer.close(index);
					}else{//单独的页面
						location.href = baseurl+"/backstage/webarticlelist";
					}
				}
			});
	}

		//初始化Ueditor
		$(function() {
			baseurl = '<%=path%>';
			/*缩略图上传*/
			var $list = $('#fileList1'), ratio = window.devicePixelRatio || 1, thumbnailWidth = 100 * ratio, thumbnailHeight = 100 * ratio, uploader;

			uploader = WebUploader.create({
				auto : true,
				swf : 'lib/webuploader/0.1.5/Uploader.swf',
				server : baseurl + '/backstage/common/uploadPic',
				pick : '#filePicker1',
				accept : {
					title : 'Images',
					extensions : 'gif,jpg,jpeg,bmp,png',
					mimeTypes : 'image/jpg,image/jpeg,image/png'
				},
				formData : {
					foldername : ''
				}
			});

			uploader.on('fileQueued', function(file) {

			});

			uploader
					.on(
							'uploadSuccess',
							function(file, response) {

								var $li = $('<li><div class="row cl"><label class="form-label col-xs-4 col-sm-3">图片：</label>'
										+ '<div class="formControls col-xs-8 col-sm-5"><img style="width: 190px; height: 190px;"'
										+' src="'+response.datas+'"><input type="hidden" value="'+response.datas+'" name="resource_url"></div></div>'
										+ '<div class="row cl"><label class="form-label col-xs-4 col-sm-3">内容：</label><div class="formControls col-xs-8 col-sm-5">'
										+ '<textarea name="resource_description" style="resize: none; width: 460px; heigth: 150px;"></textarea><button onclick="deltushuo(this)">删除</button></div></div><hr/></li>');
								$list.append($li);
							});

			uploader.on('uploadError', function(file) {
				var $li = $('#' + file.id), $error = $li.find('div.error');
				if (!$error.length) {
					$error = $('<div class="error"></div>').appendTo($li);
				}

				$error.text('上传失败');
			});

			uploader.on('uploadComplete', function(file) {
				$('#' + file.id).find('.progress').remove();
			});

		});

		function before_submit() {
			if ($('#fileList1').children().length == 0) {
				return false;
			} else {
				return true;
			}
		}

		function deltushuo(obj) {
			$(obj).parent().parent().parent().remove();
		}
	</script>
</body>
</html>

